/*
  lb1task.c:  main program for LEGObug and priority.c
              one task:  touch
*/              
#include "priority.c"

void main () {
    int pid= 0;
    
    /* touch sensor */
    process_priority[pid]= 3;
    process_name[pid]= "Touch";
    start_process(touch(pid++));
    
    /* motor arbitration process */
    num_processes= pid;
    start_process(prioritize());
}

/* touch sensor process */
void touch (int pid) {
    while (1) {
        if (left_touch()) {
            enable(pid);
            backward(pid); msleep(500L);
            right(pid); msleep(500L);
            disable(pid);
        } else if (right_touch()) {
            enable(pid);
            backward(pid); msleep(500L);
            left(pid); msleep(500L);
            disable(pid);
        }
    }
}
